<?php

if($_POST){
    $old_pass = trim($_POST['password']);
    $new_pass = trim($_POST['repassword1']);
    $rep_pass = trim($_POST['repassword2']);
    $msg = "修改成功，请使用新密码登陆！";
    if(empty($old_pass) and empty($new_pass) and empty($rep_pass)){
        $msg = "请填写完整的信息！";
    }elseif(md5($old_pass) != $_userpwd){
        $msg = "请输入正确的旧密码！";
    }elseif(strlen($new_pass) < 6){
        $msg = "密码长度不能小于6位！";
    }elseif(md5($new_pass) == $_userpwd){
        $msg = "新密码不能与旧密码相同！";
    }elseif(!preg_match("/[0-9a-zA-Z]{6,}/i",$new_pass)){
        $msg = "密码必须是数字和字母的组合，大小写敏感！";
    }elseif(md5($new_pass) != md5($rep_pass)){
        $msg = "两次输入的新密码不匹配！";
    }else{
        $new_pass = md5($new_pass);
        $sql = "UPDATE `system_user` SET `password` = '{$new_pass}' WHERE `id` = '{$_userid}' LIMIT 1";
        $db->query($sql);
    }

}
?>


